//
//  HMEmoticon.swift
//  Black22
//
//  Created by Apple on 16/11/26.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit
//  表情模型
class HMEmoticon: NSObject, NSCoding {
    //  表情描述
    var chs: String?
    //  表情图片
    var png: String?
    //  表情类型
    var type: String?
    //  emoji对应的16进制字符串
    var code: String?
    //  图片全路径
    var fullPath: String?
    //  图片所对应的文件名
    var folderName: String?
    
    
    override init() {
        super.init()
    }
    
    // MARK:    --归档和解档
    func encode(with aCoder: NSCoder) {
        aCoder.encode(chs, forKey: "chs")
        aCoder.encode(png, forKey: "png")
        aCoder.encode(type, forKey: "type")
        aCoder.encode(code, forKey: "code")
        aCoder.encode(fullPath, forKey: "fullPath")
        aCoder.encode(folderName, forKey: "folderName")
    }
    
    required init?(coder aDecoder: NSCoder) {
        chs = aDecoder.decodeObject(forKey: "chs") as? String
        png = aDecoder.decodeObject(forKey: "png") as? String
        type = aDecoder.decodeObject(forKey: "type") as? String
        code = aDecoder.decodeObject(forKey: "code") as? String
        fullPath = aDecoder.decodeObject(forKey: "fullPath") as? String
        folderName = aDecoder.decodeObject(forKey: "folderName") as? String
        //  处理图片路径
        if type == "0" {
            //  重新获取bundle路径拼接图片路径
            let imagePath = HMEmoticonTools.sharedTools.emoticonBundle.path(forResource: folderName, ofType: nil)! + "/" + png!
            fullPath = imagePath
        }
        
        
    }
    
    
}
